import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:my_app/003--项目实战-项目搭建/wechat_demo03/pages/discover/discover.dart';

// import 'pages/chat_page.dart';
// import 'package:my_app/004-第四节--项目实战-我的页面&通讯录/friends/friends_page.dart';
import 'package:my_app/004-第四节--项目实战-我的页面&通讯录/mine_page.dart';
import 'package:my_app/005--项目实战-通讯录&索引条/friends_page.dart';
// import 'package:my_app/006--项目实战-聊天界面&网络请求/chat_page.dart';
// import 'package:my_app/008--网络&项目实战/chat_page.dart';
import 'package:my_app/009--项目实战-SearchBar/chat_page.dart';

class MyApp003wechat extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.grey,
        highlightColor: Color.fromRGBO(1, 0, 0, 0.0),//透明
        splashColor: Color.fromRGBO(1, 0, 0, 0.0),//水波纹
      ),
      home: RootPage(),
    );
  }
}
class RootPage extends StatefulWidget {
  @override
  _RootPageState createState() => _RootPageState();
}

class _RootPageState extends State<RootPage> {
  int _currentIndex = 0;//默认页面
  List<Widget> _pages = [ChatPage(), FriendsPage(), DiscoverPage(), MinePage()];//DiscoverPage

  final PageController _controller = PageController(initialPage: 0);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        // body: _pages[_currentIndex],//设置界面
        body: PageView(
            physics: NeverScrollableScrollPhysics(),//不能滚动
            //页面滚动
            onPageChanged: (int index){
            _currentIndex = index;
            setState(() {
            });
        },
            controller: _controller,children: _pages),
        bottomNavigationBar: BottomNavigationBar(
          onTap: (index) {
            setState(() {
              _currentIndex = index;
            });
            _controller.jumpToPage(index);
          },
          selectedFontSize: 12.0,//选择字体大小
          currentIndex: _currentIndex,
          type: BottomNavigationBarType.fixed,
          fixedColor: Colors.green,//选择颜色
          items: [
            BottomNavigationBarItem(
              icon: Image.asset(
                'images/tabbar_chat.png',
                /*
                *  image图片配置
assets：
 - 文件夹/
’文件夹/图片名‘
                * */
                height: 20,
                width: 20,
              ),
              activeIcon: Image.asset(
                'images/tabbar_discover_hl.png',
                height: 20,
                width: 20,
              ),
              title: Text('薪信'),
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.chat),
              title: Text('通讯录'),
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.chat),
              title: Text('发现'),
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.chat),
              title: Text('我'),
            ),
          ],
        ),
      ),
    );
  }
}
